package com.situ.mall.controller;


import com.situ.mall.pojo.entity.Category;
import com.situ.mall.pojo.vo.CategoryVO;
import com.situ.mall.service.ICategoryService;
import com.situ.mall.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author
 * @since 2025-09-10
 */
@RestController
@RequestMapping("/product/category")
public class CategoryController {

    @Autowired
    private ICategoryService categoryService;

    @GetMapping("/selectTopCategoryList")
    public Result<List<CategoryVO>> selectTopCategoryList() {
        List<CategoryVO> list = categoryService.selectTopCategoryList();
        return Result.ok(list);
    }

    @GetMapping("/selectSecondCategoryListByParentId/{id}")
    public Result<List<Category>> selectSecondCategoryListByParentId(@PathVariable Integer id) {
        List<Category> list = categoryService.selectSecondCategoryListByParentId(id);
        return Result.ok(list);
    }
}

